/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package properties;

import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.Properties;

/**
 *
 * @author Stefan Martinov <stefan.martinov@gmail.com>
 */
public class PropertyHolder {

    private static final PropertyHolder holder = new PropertyHolder();
    private Properties properties;
    public static final String className = "PropertyHolder";
    public static final String propertyFileName = "Settings.properties";

    private PropertyHolder() {
        URL url = PropertyHolder.class.getResource(propertyFileName);
        File file = new File(url.getFile());
        try {
            properties = new Properties();
            properties.load(new FileInputStream(file));
        } catch (Exception e) {
            e.printStackTrace();
            System.err.println("Error in loading properties from location " + url.getFile() + propertyFileName);
        }
    }

    public static String getProperty(String propertyName) {
        return holder.getProperties().getProperty(propertyName);
    }

    protected Properties getProperties() {
        return properties;
    }

    protected void setProperties(Properties properties) {
        this.properties = properties;
    }

    public static String getProjectName() {
        return holder.getProperties().getProperty("PROJECT_NAME");
    }
}
